// 密码相关

import axios from "axios";

// 修改密码
export function changePassword(oldPassword, newPassword) {
    return axios({
        method: "put",
        url: "/api/users/password?type=change",
        data: {
            oldPassword,
            newPassword
        },
        header: {
            Authorization: localStorage.getItem("Authorization")
        }
    }).then(response => {
        return {
            result: true,
            data: response.data
        }
    }).catch(error => {
        return {
            result:false,
            msg: error.response.data.msg
        }
    })
}

// 重置密码
export function resetPassword(account, password) {
    return axios({
        method: "put",
        url: "/api/users/password?type=reset",
        data: {
            account, password
        },
        header: {
            Authorization: localStorage.getItem("Authorization")
        }
    }).then(response => {
        return {
            result: true,
            data: response.data
        }
    }).catch(error => {
        return {
            result: false,
            msg: error.response.data.msg
        }
    })
}